<?php
/**
 * Created by PhpStorm.
 * User: ls721
 * Date: 2016/10/28 0028
 * Time: 21:17
 */class Domain_Work{

    public function listWork($doctor_id)
    {
        $model = new Model_Work();
        $rs=$model->listWork($doctor_id);
        return $rs;
//        if(empty($rs)){ return "暂无出诊信息";}
//        else{return $rs;}

    }

    public function getWork($work_id)
    {
        $model = new Model_Work();
        $rs1 =  $model->getWorkSingle($work_id);
        $model_Event = new Model_Event();
        $rs2 = $model_Event->getEventInfo($rs1["EventId"]);
        return array_merge($rs2, $rs1);
    }
    public function listDoctorOfEvent($event_id){
        $model=new Model_Work();
        return $model->listDoctorOfEvent($event_id);
    }

    public function listDoctorOfWork($event_id,$lng,$lat)
    {
        $model = new Model_Work();
        $rs = $model->listDoctorOfWork($event_id);
        $domain=new Domain_Doctor();
        // array_splice($rs,1,1);
        $i = 0;
        for ($i=0;$i<count($rs);$i++) {
            $value= $rs[$i];
            $dis=$domain->getDistance($lng, $lat, $value['Lng'], $value['Lat']);
            $value["Distance"]=$dis;
            $rs[$i]=$value;


        }
        //var_dump($model->listDoctors());
        return $rs;
    }
}